﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ICUP13.Management;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;
using ICUP13.Texture;

namespace ICUP13.States
{
    public class SplashScreenState : IBaseState
    {
        TextureManager tm = TextureManager.GetInstance();
        // Constructor
        public SplashScreenState() { }
        private float _elapsedTime = 0;
        private float _splashScreenDuration = 3;

        // State Methods
        public override void Enter()
        {
            _elapsedTime = 0;
            _splashScreenDuration = 3;
        }
        public override void Exit()
        {

        }
        public override bool Input(float Delta, float TotalElapsed, int FPS)
        {
            KeyboardState CurrentState = Keyboard.GetState();

            if (CurrentState.IsKeyDown(Keys.Escape))
                return false;

            return true;
        }

        public override void Update(float Delta, float TotalElapsed, int FPS)
        {
            _elapsedTime += Delta;
            if (_elapsedTime > _splashScreenDuration)
                StateMachine.ChangeStateQueue(new MainMenuState());
        }

        public override void Draw(float Delta, float TotalElapsed, int FPS)
        {
            clearScreen(TotalElapsed);
            MainGame.Batch.Draw(tm.SplashScreenBackground, MainGame.ClientRect, Color.White);
        }

        private void clearScreen(float TotalElapsed)
        {
            MainGame.Device.Clear(new Color(1.0f, 0, 0, 1f));
        }

    }
}
